通过一个 coupon_template 对象在指定用户下创建一个 coupon 对象用于生成一张优惠券,coupon 对象的有效时间根据关联的 coupon_template 对象由系统自动计算得出,可以在有效时间内在订单创建时使用。
| 属性 | 描述 | 
|---|---|
| id string | 优惠券对象 ID,由 Ping++ 生成。 | 
| object string | 值为 "coupon"。 | 
| app string | 对应 app对象的id,查看 如何获取App ID。 | 
| created int | 创建时间,用 Unix 时间戳表示。 | 
| livemode boolean | 是否处于 live 模式。 | 
| valid boolean | 是否可用。优惠券过期、优惠券已使用、关联的优惠券模板删除会使该优惠券变为不可用。 | 
| redeemed boolean | 是否已经使用(核销)。 | 
| coupon_template hash | 关联的 coupon_template对象。 | 
| user string | user对象的id。 | 
| time_start timestamp | 可用的开始时间,用 Unix 时间戳表示。 | 
| time_end timestamp | 可用的结束时间,用 Unix 时间戳表示。 | 
| order string | 关联 order对象的id。使用后生效。 | 
| actual_amount int | 关联 order对象的应付金额,单位为分。使用后生效。 | 
| user_times_circulated int | 优惠券在该用户下当前生成次数。 | 
| metadata hash | 详见 元数据。 | 
{
   "id": "COUPON_ID",
   "object": "coupon",
   "app": "APP_ID",
   "actual_amount": null,
   "coupon_template": {
       "id": "300116082415452100000700",
       "object": "coupon_template",
       "app": "APP_ID",
       "amount_available": 10000,
       "amount_off": 25,
       "created": 1470904889,
       "expiration": null,
       "livemode": false,
       "max_circulation": 1000,
       "metadata": {
       },
       "name": "25 OFF",
       "percent_off": null,
       "refundable": true,
       "times_circulated": 0,
       "times_redeemed": 0,
       "type": 1
   },
   "created": 1470969003,
   "livemode": false,
   "metadata": {
   },
   "order": null,
   "user_times_circulated":1,
   "redeemed": false,
   "time_end": 1472265014,
   "time_start": 1470969010,
   "user": "USER_ID",
   "valid": true
}